using System.Collections;
using System.Collections.Generic;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;

public class RankListController : MonoBehaviour
{
    public GameObject RankItem;
    public Transform Content;
    DataManager dataManager;

    private void Awake()
    {
        dataManager = DataManager.Instance;
    }

    void Start()
    {
        for(int i = 0; i < dataManager.HighScores.Count; i++)
        {
            GameObject rankItem = Instantiate(RankItem,Content);
            TMP_Text[] texts = rankItem.GetComponentsInChildren<TMP_Text>();
            for (int j = 0; j < texts.Length; j++)
            {
                if (texts[j].name == "Rank_RankItem")
                {
                    texts[j].text = (i + 1).ToString();
                }else if (texts[j].name == "Score_RankItem")
                {
                    texts[j].text = dataManager.HighScores[i].ToString();
                }
            }
            
        }
    }
}
